home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / editor / xes.lha / XES / S / c-mode.xrc < prev    next >
Text File  |  1995-08-23  |  4KB  |  92 lines

  1. # $VER: c-mode.xrc 1.2 (23 Aug 1995)
  2. #C Mode
  3.  
  4. setmacro c-mode 0 (Mx-f settvar mode (ANSI C) settvar ccq zM settvar ftab C_tab settvar rbrace C_brace map Mc-t AIC-indent)
  5. setmacro krc-mode 0 (Mx-f settvar mode (K&R C) settvar ccq zM settvar ftab C_tab settvar rbrace C_brace map Mc-t KRC-indent)
  6.  
  7. # This properly indents a single line of C code or all the lines of C
  8. # code in a block.
  9. setmacro C_tab 0 (ifelse cb (goto block while cb (Mc-t down) goto block) Mc-t)
  10.  
  11. # Properly positions a right brace when you type one.
  12. setmacro C_brace 0 ((}) ping 9 firstnb ifelse c="}" Mc-1 (pong 9))
  13.  
  14. # Properly indents a line for ANSI/ISO Standard C and for C++
  15. # Left braces always go at the ends of lines.
  16.  
  17. setmacro AIC-indent 0 (indent . -255 first ifelse c="{" (up join) (Mc-g Mcs-2))
  18.  
  19. # Properly indents a line for the original Kernighan & Richie C
  20. # Left braces may go on their own lines.
  21. setmacro KRC-indent 0 (indent . -255 first ifelse c="{" (up firstnb set m (\$colno) down) Mc-g Mcs-2)
  22.  
  23. # This calculates which column a line should begin on.
  24.  
  25. setmacro c-getcol 0 (set m 1 do (when c="#" nop when c="else" c-else when c="}" Mc-2 Mc-f if 5 (ping 9 wleft ifelse c="else" Mcs-0 (last left do (when c=41 Mcs-0 when c="," Mc-, Mc-;)))))
  26. map Mc-g (set m 1 if c<>"#" (ifelse c="else" Mc-e (ifelse c="}" Mc-2 (Mc-f if 5 (ping 9 wleft ifelse c="else" Mcs-0 (last left ifelse c=41 Mcs-0 (ifelse c="," Mc-, Mc-;)))))))
  27.  
  28. # This sets the indentation mark one tab length forward.
  29. map Mcs-0 (firstnb tab set m (\$colno) pong 9)
  30.  
  31. map Mc-; (pong 9 insert (}) left force s match sc-l if c="{" (force s firstnb if c="switch" (force s tab) set m (\\\$colno) pong 9) del add m 4 last if !l (left if c=":" (sub m 4)) pong 9)
  32. map Mc-, (pong 9 insert (}) left force s match sc-l if c="{" (force s firstnb if c="switch" (force s tab) tab set m (\\\$colno) pong 9) del add m 4 last if !l (left if c=":" (sub m 4)) pong 9)
  33.  
  34. # If the line isn't blank, this checks whether a left brace reigns
  35. # over the current line.  Toggle 5 is reset if one doesn't, which
  36. # will usually be for comments in the preprocessor code.
  37. map Mc-f (flag 5 1 if !r (insert (}) left force s match ifelse c="{" (force s match) (flag 5 0) del))
  38.  
  39. #map Mcs-2 (ifelse r (col (\$m)) (split col (\$m) join))
  40.  
  41. # This does the actual indenting after it is determined which column
  42. # a line should begin at.
  43. map Mcs-2 (ifelse r (col (\$m)) (indent . (\$m) indent . -1 last))
  44.  
  45. map Mc-1 (ping 9 force s match force s firstnb setx pong 9 del gox (}))
  46.  
  47. # This finds out how to indent a right brace by finding the line
  48. # with its matching left brace, which it aligns it with.
  49. map Mc-2 (ping 9 force s match force s firstnb set m (\$colno) pong 9)
  50.  
  51. # This checks whether the preceding line contains an "if", an "else",
  52. # an "else if", or a right brace.  It sets toggle 5 if it doesn't.
  53. # This is for using it in a while loop until it finds a line which
  54. # begins in one of these ways.
  55.  
  56. map Mc-L (flag 5 0 up firstnb if c="}" (match firstnb) do (when c="if" nop when (c="else if") nop when c="else" backtab flag 5 1))
  57.  
  58. # This searches for the line that will indicate how an "else" line should
  59. # be indented.  It will be aligned with it if it begins with an "if", an
  60. # "else if" or a right brace.  But if it's another "else" line, it will
  61. # be indented one tab length to its left.
  62. setmacro c-else 0 (ping 9 flag 5 1 while 5 Mc-L set m (\$colno) pong 9)
  63. map Mc-e c-else
  64.  
  65. map zM-/ insert-border
  66. map zM-] justify-comment
  67. map zM-a ((auto ))
  68. map zM-b ((break;))
  69. map zM-c ((case ))
  70. map zcM-c ((continue;))
  71. map zcM-d ((default:))
  72. map zM-d ((#define ))
  73. map zM-e ((else ))
  74. map zcM-e ((extern ))
  75. map zM-f ((for ()) left)
  76. map zM-g ((goto ))
  77. map zcM-i ((int main (int argc, char **argv) {))
  78. map zM-i ((#include ))
  79. map zM-l ((long ))
  80. map zM-m ((int main () {))
  81. map zM-p ((printf ("");) 3 left)
  82. map zM-r ((return))
  83. map zcM-r ((register ))
  84. map zM-s ((switch ))
  85. map zcM-s ((struct ))
  86. map zM-t ((typedef ))
  87. map zM-u ((unsigned ))
  88. map zcM-u ((union ))
  89. map zM-v ((void ))
  90. map zcM-v ((volatile ))
  91. map zM-w ((while ()) left)
  92.